package com.zhaotianhao.interceptor;

import com.zhaotianhao.pojo.Users;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author Z-7
 * @Date 2022/3/5
 */
public class LoginInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Users login_user = (Users) request.getSession().getAttribute("LOGIN_USER");
        if(login_user == null){
            response.sendRedirect("/user/login");
            return false;
        }
        return true;
    }
}
